Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

Python wheels currently embed all C++ code into the pybind module via static linking. This PR separates them: pybind module now dynamically links to libOpen3D.so/dylib/dll, both packaged in the wheel.

Changes

Core build logic:

  • Change default value of BUILD_SHARED_LIBS from OFF to ON in CMakeLists.txt
  • This allows users to still build with static libOpen3D by explicitly setting -DBUILD_SHARED_LIBS=OFF if needed
  • Existing package infrastructure already copies and bundles both files correctly

CI/Docker updates:

  • Remove BUILD_SHARED_LIBS=OFF from:
    • docker/Dockerfile.wheel
    • util/ci_utils.sh (build_pip_package function)
    • .github/workflows/windows.yml (wheel build)
  • Remove STATIC_WINDOWS_RUNTIME=ON from Windows wheel build (shared libs require DLL runtime)

macOS fix:

  • Remove NOT BUILD_SHARED_LIBS condition from OpenMP library packaging (previously unhandled)

Result

By default, wheels now contain:

open3d/
├── pybind.so           # Python bindings (small)
└── libOpen3D.so.X.Y    # C++ library (large)

Instead of:

open3d/
└── pybind.so           # Everything statically linked (large)

Users can still build Python bindings with static libOpen3D by explicitly setting BUILD_SHARED_LIBS=OFF if needed for custom builds.

User code unchanged: import open3d works identically.

Original prompt

Task:
Open3D python bindings are created as a single DLL (named pybind) that contains both the compiled C++ code and the python binding code. Separate this, so that pybind DLL instead always loads libOpen3D.so DLL. Propagate this change to docker files and CI for wheel building.

Agent instructions for Open3D:
Open3D contains 3D data processing and machine learning code that runs on CPU, CUDA (Nvidia) GPUs and SYCL / OneAPI (Intel) GPUs.
All new or updated functionality should:

  • Be written in C++17, CUDA and SYCL2020 and exposed through Python bindings (folder cpp/pybind). CUDA and SYCL support is optional.
  • Have unit tests (C++ unit tests in cpp/tests folder and non-trivial Python features in python/tests folder).
  • Have C++ (Doxygen) docs in the C++ header files and Python (Sphinx Google style rst format) docs in the pybind files. Include simple usage examples in the docs as appropriate.
  • Run clang-format and yapf to format code. C++ code must not produce compiler (g++ / clang++) warnings and any linting issues (e.g. clang-tidy reporting missing include header) should be resolved if feasible.
    For CI and dependencies:
  • CUDA and OneAPI API version should be compatible with the PyTorch versions (python/requirements*.txt).
  • When updating dependencies, prefer the highest available version that is compatible with other dependencies and Open3D usage.
  • Open3D builds must run on the oldest supported Ubuntu LTS (e.g. Ubuntu 20.04 before April 2025), and Windows and macOS versions that are atleast 5 years old. Similarly, 5 year old Python versions are supported (aligning with Pythin official support).

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Oct 31, 2025
@update-docs
Copy link

update-docs bot commented Oct 31, 2025

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

Copilot AI and others added 4 commits October 31, 2025 23:53
- Modified CMakeLists.txt to automatically set BUILD_SHARED_LIBS=ON when BUILD_PYTHON_MODULE=ON
- Updated Dockerfile.wheel to remove explicit BUILD_SHARED_LIBS=OFF
- Updated Windows workflow to remove explicit BUILD_SHARED_LIBS=OFF for wheel builds
- Updated ci_utils.sh to remove BUILD_SHARED_LIBS=OFF from pip package builds
This ensures pybind module dynamically links to libOpen3D.so instead of statically embedding it

Co-authored-by: ssheorey <[email protected]>
- Removed the NOT BUILD_SHARED_LIBS condition from OpenMP library packaging
- Now packages libomp for macOS regardless of build type since Python builds always use shared libs

Co-authored-by: ssheorey <[email protected]>
- Removed explicit STATIC_WINDOWS_RUNTIME=ON from Windows wheel workflow
- When BUILD_SHARED_LIBS=ON (now automatic for Python), STATIC_WINDOWS_RUNTIME defaults to OFF
- Shared libraries should use DLL runtime (/MD) instead of static runtime (/MT)

Co-authored-by: ssheorey <[email protected]>
- Added conditional message only when BUILD_SHARED_LIBS was OFF
- Clarified why shared libraries are required for Python module

Co-authored-by: ssheorey <[email protected]>
Copilot AI changed the title [WIP] Separate pybind DLL from libOpen3D loading Separate pybind module from libOpen3D shared library in Python wheels Nov 1, 2025
Copilot finished work on behalf of ssheorey November 1, 2025 00:03
Copilot AI requested a review from ssheorey November 1, 2025 00:03
@ssheorey
Copy link
Member

ssheorey commented Nov 1, 2025

@copilot Do not change CMakeLists.txt, i.e. allow the option of building python bindings with a static libOpen3D. Instead only change CI, build scripts and docker files to build Python wheels with a shared libOpen3D. However, update the default value of BUILD_SHARED_LIBS=ON, since BUILD_PYTHON_MODULE=ON by default.

- Reverted the CMakeLists.txt logic that forced BUILD_SHARED_LIBS=ON when BUILD_PYTHON_MODULE=ON
- Changed the default value of BUILD_SHARED_LIBS from OFF to ON
- This allows users to build Python bindings with static libOpen3D if desired
- Updated Dockerfile.wheel comment to reflect the new approach
- CI/Docker/build scripts still remove explicit BUILD_SHARED_LIBS=OFF to use the default

Co-authored-by: ssheorey <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot Do not change CMakeLists.txt, i.e. allow the option of building python bindings with a static libOpen3D. Instead only change CI, build scripts and docker files to build Python wheels with a s...

Done. Changed BUILD_SHARED_LIBS default to ON instead of forcing it. This allows building Python bindings with static libOpen3D if explicitly set to OFF, while CI/Docker/build scripts use the new default (ON) for wheel builds. See commit fe53c51.

Copilot finished work on behalf of ssheorey November 1, 2025 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants